<template>
	<view>
		<view class="" style="height: 260rpx;"></view>
		<!-- <view class="box_MY_bjt" :style="{ 'background-image': `url(${YQ_BJT})` }"> -->
		<view class="box_MY_bjt">
			<view class="" style="width: 160rpx;margin: 0 auto;height: 100rpx;">
				<image :src="avatar" class="box_MY_bjt_tx" mode=""></image>

			</view>
			<view class="" style="font-size: 32rpx;font-weight: 700;color: #333;text-align: center;">我的邀请码</view>
			<view class="MT_10" style="font-size: 32rpx;font-weight: 700;color: #333;text-align: center;">
				{{invite_code}}
			</view>
			<view class="" style="width: 300rpx;margin: 0 auto; margin-top: 50rpx;">
				<image :src="erweima" style="width: 300rpx;height: 300rpx;" mode=""></image>

			</view>

			<view class="MT_10" style="color: #FFA94E;
		font-weight: 700;
		font-size: 32rpx;
		text-align: center;
		">长按保存图片</view>
			<!-- <view class="dispJC dispAI" style="width: 87%;margin: 0 auto;margin-top: 36rpx;position: relative;">
				<view class="box_MY_bjt_AN1" @click="onSave">保存图片</view>
			</view> -->
			<view class=""
				style="width: 610rpx;height: 0rpx;border: 2rpx dashed #E5E5E5;margin: 0 auto; margin-top: 60rpx;">
			</view>
		</view>
	</view>
</template>

<script>
	import{invite,userinfo}from "@/api/api.js"
	export default {
		data() {
			return {
				invite_rule: "",
				avatar: "",
				erweima: "",
				invite_code: ""
			}
		},
		onLoad() {
			this.token = window.sessionStorage.getItem('token')
			this.get_user_info()
			this.getFuJiID()

		},
		methods: {
			// 获取二维码
			async getFuJiID() {
				let res = await invite()

				this.erweima = res.data
			},



			// 获取用户信息
			async get_user_info() {
				let res = await userinfo()
				console.log(res, '获取用户信息');
				this.avatar = res.data.avatar
				this.invite_code = res.data.invite_code
			},
			// 保存图片
			onSave() {
				console.log(this.erweima);
				uni.downloadFile({
					url: this.erweima,
					success(res) {
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success() {
									uni.$u.toast("保存图片成功~");
								},
								fail(err) {
									console.error('保存图片失败', err);
								}
							});
						}
					},
					fail(err) {
						console.error('下载图片失败', err);
					}
				});
			}
		},

	}
</script>

<style scoped lang="scss">
	.shareBtn1::after {
		border: none;
	}

	.shareBtn1 {
		background-color: transparent;
		height: 97rpx;
		position: absolute;
		top: -4rpx;
		left: 326rpx;
		width: 280rpx;
		border: none !important;
		outline: none !important;
	}


	.box_MY_bjt_AN2 {
		width: 290rpx;
		height: 88rpx;
		background: linear-gradient(90deg, #F8BF68 0%, #FCAA2A 100%);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #FFFFFF;
		text-align: center;
		line-height: 88rpx;
	}

	.box_MY_bjt_AN1 {
		width: 290rpx;
		height: 88rpx;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		opacity: 1;
		border: 2rpx solid #FCAA2A;
		text-align: center;
		line-height: 88rpx;
		color: #FFA94E;
		font-weight: 700;
		box-sizing: border-box;
		font-size: 32rpx;
		margin: 0 auto;
	}

	.box_MY_bjt_tx {
		width: 160rpx;
		height: 160rpx;
		border-radius: 50%;
		transform: translate(0rpx, -80rpx);
	}

	.box_MY_bjt {
		width: 700rpx;
		height: 762rpx;
		background-image: url('http://ttx-product-1317781948.cos.ap-nanjing.myqcloud.com/upload/imgs/user/202309/12/WDYi1RU1zTvtDu3TL6AgsiPy4qqsjZ7vlMvm6YAC.png');
		background-size: 100% 100%;
		background-position: center;
		background-repeat: no-repeat;
		margin: 0 auto;
	}
</style>